Fix #541: Track and display per-project agent time in analytics#555
Merged
waleedkadous merged 2 commits intomainfrom Feb 24, 2026
Merged
Conversation
Add Phase 1 (consultation-based estimate) of agent time tracking: - MetricsDB.agentTimeByProtocol() aggregates consultation durations by project, then averages per protocol - Analytics server merges agent time into ProtocolStats alongside wall clock time, with graceful fallback on failure - Dashboard shows agent time next to wall clock in Activity section 112 LOC net diff across 5 files.
Address CMAP review feedback: dashboard analytics test fixture was missing the new avgAgentTimeHours property on ProtocolStats.
Contributor
Author
Architect ReviewLow-medium risk. Clean addition of per-project agent time tracking to analytics.
Approved. Architect review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Phase 1 agent time tracking to the analytics dashboard by summing consultation durations from MetricsDB per project and averaging by protocol.
Fixes #541
Root Cause
The analytics dashboard tracked wall clock time per protocol but had no visibility into how much actual agent compute time each project consumed. MetricsDB already records per-consultation
duration_secondswithproject_idandprotocolfields, but no aggregation existed to surface this data.Fix
metrics.ts): AddedagentTimeByProtocol()method — a subquery groups consultations by(protocol, project_id), sums durations per project, then averages across projects per protocolanalytics.ts): ExtendedProtocolStatswithavgAgentTimeHours, computed from MetricsDB data with graceful fallback if DB is unavailableapi.ts,AnalyticsView.tsx): Display agent time alongside wall clock time in the Activity section's Projects by Protocol metricsTest Plan